<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/15 0015
 * Time: 14:07
 */


$http = new swoole_http_server("0.0.0.0", 9501);

$http->on('request', function ($request, $response) {
    if ($request->server['path_info'] == '/favicon.ico' || $request->server['request_uri'] == '/favicon.ico') {
        return $response->end();
    }

    //url路由
    list($controller, $action) = explode('/', trim($request->server['request_uri'], '/'));
    var_dump($controller, $action);
    //根据 $controller, $action 映射到不同的控制器类和方法
    //(new $controller)->$action($request, $response);

    var_dump($request->get, $request->post);
    $response->header("Content-Type", "text/html; charset=utf-8");
    $response->end("<h1>Hello Swoole. #".rand(1000, 9999)."</h1>");
});

$http->start();

/*
启动服务
php http_server.php
可以打开浏览器，访问http://127.0.0.1:9501查看程序的结果。
也可以使用apache ab工具对服务器进行压力测试
*/


